<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>layout 后台大布局 - Layui</title>
  <link th:href="@{/layui/css/layui.css}" rel="stylesheet"/>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">权限管理</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;" id = "user_message">

        </a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:;" id="user_info">基本资料</a></dd>
          <dd><a href="javascript:;" id="user_password">安全设置</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="#" id="exit">退了</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">

      </ul>
    </div>
  </div>
  
  <div class="layui-body">

    <div class="layui-tab" lay-filter="demo" lay-allowclose="true">
      <ul class="layui-tab-title"></ul>
      <div class="layui-tab-content"></div>
    </div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © duanlsh
  </div>
</div>
<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/js/index.js}"></script>
<script th:inline="javascript">
  layui.use('form', function() {
    var $ = layui.jquery;
    var user = layui.data("user_table").user;
    var header = "<img src='" + user.picUrl + "' class='layui-nav-img'/>";
    var username = user.name;
    $("#user_message").append(header);
    $("#user_message").append(username);

    var token = layui.data("user_token");
    console.log(user);

    $("#user_info").click(function () {
      layer.open({
        type: 2,
        title: "用户资料",
        // skin: 'layui-layer-rim',
        area:  ['400px', '250px'],
        offset: '20px',
        content: '/user/page/user-info/' + user.id
      });
    });

    $("#user_password").click(function () {
      layer.open({
        type: 2,
        title: "修改密码",
        // skin: 'layui-layer-rim',
        area:  ['400px', '250px'],
        offset: '20px',
        content: '/user/page/user-password'
      });
    });


    $("#exit").click(function () {

      $.ajax({
        type: 'post',
        url: '/sys-user/login-out',
        dataType: 'json',
        contentType: 'application/json; charset=utf-8',
        headers: {
          token:token.token
        },
        success: function (raw_data) {
          if (raw_data.code === 1){
            layer.msg("退出成功!");
          } else {
            layer.msg(raw_data.message);
          }
        }
      });

      layui.data('user_token', null);
      layui.data('user_table', null);
      layui.data('role_id_list_table', null);
      location.href="/";
    });
  });
</script>
</body>
</html>